<template>
	<view>
		<!-- #ifdef APP-PLUS -->
		<view class="status_bar"></view>
		<!-- #endif -->
		<view class="head">
			<image src="../../static/images/arrow_left.png" mode="" @click="$back()"></image>
			<view class="">开单</view>
			<view class=""></view>
		</view>

		<view class="information">
			<view class="name">
				<view class="">* 姓名</view>
				<input type="text" value="" placeholder="请输入供应商名称" v-model="name" />
			</view>
		</view>
		<view class="informationtwo">
			<view class="name">
				<view class="">* 手机号</view>
				<input type="text" value="" placeholder="请输入手机号" v-model="telephone" />
				<image src="../../static/client/phone.png" mode="" @click="visitContacts()"></image>
			</view>
		</view>

		<button type="primary" @click="goBil">保存</button>
	</view>
</template>

<script>
	  import nativeCommon from '../../js_sdk/WH-VisitContacts/native.common.js';
export default {
	data() {
		return {
			telephone: '',
			name: '',
			customer_id: '',
			add: {},
			da:'api/v1.customer/edit'
		};
	},
	onLoad(e) {
		if(uni.getStorageSync('kaidan')==-5){
			// console.log(123);
			this.da='api/v1.customer/add'
			return
		}
		this.add = JSON.parse(e.item);
		console.log(this.add);
		this.name = this.add.name;
		this.telephone = this.add.telephone;
		this.customer_id = this.add.customer_id;
	},
	methods: {
		visitContacts() {
		let that=this;
		            nativeCommon.contacts.getContact(function(name, number){
		        that.name=name
		        that.telephone=number
				
		
		            });
		        },
		goBil() {
			this.$ajax(this.da, {
				name: this.name,
				telephone: this.telephone,
				customer_id: this.customer_id
			})
				.then(res => {
					console.log(res);
					this.add = res.result;
					uni.removeStorage({
						key:'kaidan'
					})
					uni.navigateTo({
						url: '../order/billing?item=' + JSON.stringify(this.add) + '&index=' + JSON.stringify(-1)
					});
				})
				.catch(res => {
					console.log(Error);
				});
		},
		goBil2() {
			uni.navigateTo({
				url: '../shop/exhibit'
			});
		}
	}
};
</script>

<style lang="scss">
page {
	background-color: #f7f4f8;
}
.status_bar {
	height: var(--status-bar-height);
	width: 100%;
}
.head {
	height: 88rpx;
	line-height: 88rpx;
	background-color: #249af6;
	color: #ffffff;
	display: flex;
	justify-content: space-between;
	padding: 0 30rpx;
	margin-bottom: 30rpx;
	font-size: 36rpx;
	font-family: PingFang SC;
	font-weight: 500;
	image {
		width: 22rpx;
		height: 39rpx;
		margin-top: 25rpx;
	}
}
.information {
	.name {
		padding: 31rpx 38rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: 500;
		height: 105rpx;
		background-color: #ffffff;
		border-bottom: 2rpx solid #eeeeee;
		input {
			text-align: right;
		}
	}
	image {
		width: 44rpx;
		height: 44rpx;
	}
}
.informationtwo {
	.name {
		padding: 31rpx 38rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: 500;
		height: 105rpx;
		background-color: #ffffff;
		border-bottom: 2rpx solid #eeeeee;
		input {
			text-align: right;
			position: relative;
			left: 60rpx;
		}
	}
	image {
		width: 44rpx;
		height: 44rpx;
	}
}
.tui {
	margin-top: 20rpx;
	height: 110rpx;
	background-color: #ffffff;
	padding: 41rpx 38rpx;
	box-sizing: border-box;
	font-size: 30rpx;
	font-family: PingFang SC;
	font-weight: 500;
	color: rgba(51, 51, 51, 1);
	display: flex;
	border-bottom: 2rpx solid #eeeeee;
	justify-content: space-between;
	image {
		width: 18rpx;
		height: 33rpx;
	}
}
.zhe {
	padding: 30rpx 38rpx;
	box-sizing: border-box;
	background-color: #ffffff;
	font-size: 32rpx;
	.zheTop {
		display: flex;
		justify-content: space-between;
		.right {
			color: red;
			font-size: 32rpx;
		}
	}
	.zheBot {
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(102, 102, 102, 1);
		margin-top: 20rpx;
	}
}
// 全部分类
.classify {
	width: 100%;
	background-color: $white-background;
	padding: 30upx 0 0 0;
	.tit {
		border-bottom: 2upx #eee solid;
		padding: 0 30upx 35upx 30upx;
	}
	.select-item {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		border-bottom: 2upx #eee solid;
		padding: 0 30upx 30upx;
		margin-top: 35upx;
		.arrow {
			image {
				width: 38upx;
				height: 38upx;
			}
		}
	}
}
button {
	width: 100%;
	position: fixed;
	bottom: 0;
}
.jie {
	margin-left: 300rpx;
}
</style>
